﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model;
using System.Windows.Forms;

namespace PJRScrum
{
    class ImportGuiPanelFour : ImportGuiPanel
    {
        private System.Windows.Forms.Button btn_Opslaan;

        public ImportGuiPanelFour()
        {
            InitializeComponent();
        }

        private void InitializeComponent()
        {
            this.btn_Opslaan = new System.Windows.Forms.Button();
            this.SuspendLayout();
            // 
            // btn_Opslaan
            // 
            this.btn_Opslaan.Location = new System.Drawing.Point(129, 64);
            this.btn_Opslaan.Name = "btn_Opslaan";
            this.btn_Opslaan.Size = new System.Drawing.Size(170, 51);
            this.btn_Opslaan.TabIndex = 0;
            this.btn_Opslaan.Text = "Opslaan";
            this.btn_Opslaan.UseVisualStyleBackColor = true;
            this.btn_Opslaan.Click += new System.EventHandler(this.btn_Opslaan_Click);
            // 
            // ImportGuiPanelFour
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.Controls.Add(this.btn_Opslaan);
            this.Name = "ImportGuiPanelFour";
            this.ResumeLayout(false);
        }

        bool opgeslagen;
        public bool Opgeslagen { get { return opgeslagen; } }
        private void btn_Opslaan_Click(object sender, EventArgs e)
        {
            ObjectToSerialize ost = new ObjectToSerialize();
            ost.Winkel = Winkel.GetInstance();

            SaveFileDialog sfd = new SaveFileDialog();
            sfd.Title = "Opslaan";
            sfd.Filter = "PJR bestand|*.pjr";
            
            sfd.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop);

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                Serializer serializer = new Serializer();
                serializer.SerializeObject(sfd.FileName, ost);
                opgeslagen = true;
            }           
        }
    }
}
